package com.bosssoft.hr.train.springboot.service;


import com.bosssoft.hr.train.springboot.dao.UserMapper;
import com.bosssoft.hr.train.springboot.demo.User;
import com.bosssoft.hr.train.springboot.util.MyBatisUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: wang
 * @Time: 2022/3/10
 */
@Service
public class UserServiceImpl implements com.bosssoft.hr.train.springboot.service.UserService {

UserMapper mapper= MyBatisUtil.getSession().getMapper(UserMapper.class);

    public boolean save(User user) {
        if (mapper.add(user)<=0){
            return false;
        }else
        return true ;
    }

    public boolean remove(Integer id) {
        if (mapper.delete(id)<=0){
            return false;
        }else
        return true;
    }

    public boolean update(User user) {
        if (mapper.update(user)<=0){
            return false;
        }else
        return true;
    }

    public List<User> findByName(String name) {

        return mapper.select(name);
    }
}
